#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>

using namespace std;
const int MOD = 1e9 + 7, N = 55;

typedef long long LL;
int a[N];
int main()
{
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	LL ret = 1;
	for (int i = 1; i <= n; i++)
	{

		ret = ret *(a[i] - i + 1) % MOD;
	}
	if (a[n] < n) cout << 0 << endl;
	else cout << ret << endl;
	return 0;
}